﻿@model IEnumerable<BskLeague.Models.Player>

@{
    ViewBag.Title = "Zawodnicy";
}

<center><h2>Zawodnicy</h2>
<table cellspacing="0" cellpadding="0" width="70%">
    <tr>
        <td colspan="3" align="center">
            <
            @for(int i=0; i<@ViewBag.LettersList.Count; i++)
            {
                <text>
                <font size="2">@Html.ActionLink((string)@ViewBag.LettersList[i].ToString(), "Index", new { letter = @ViewBag.LettersList[i] })
                <text>-</text>
                </text>
            }
            @Html.ActionLink("Pokaż wszystkich", "Index", new { letter = '0' })</font>
            >
        </td>
    </tr>
    <tr>
        <th style="text-align:center;">Zawodnik</th>
        <th style="text-align:center;">Drużyna</th>
        <th style="text-align:center;">Ostatni Sezon</th>
    </tr>
    @for (int i = 0; i < ViewBag.PlayerID.Count; i++)
    {
        <tr style="text-align:center;">
            <td>@Html.ActionLink((string)@ViewBag.PlayerName[i], "Details", new { id = ViewBag.PlayerID[i] })</td>
            <td>@Html.ActionLink((string)@ViewBag.TeamName[i], "Details", "Team", new { id = ViewBag.TeamID[i] }, null)</td>
            <td>@Html.ActionLink((string)@ViewBag.LastSeasonName[i]+" ("+(string)@ViewBag.LastSeasonStatus[i]+")", "Index", "Schedule") </td>
        </tr>
    }
    @if(@ViewBag.TotalItemsCount > @ViewBag.Take)
    {
    <tr>
        <th colspan=5>
            <center>
                <
                @{
                    int temp=@ViewBag.TotalItemsCount/@ViewBag.Take;
                    temp=((@ViewBag.TotalItemsCount%@ViewBag.Take)!=0)? ++temp: temp;
                }
                @for (int i = 0; i < temp; i++)
                {   
                    if(@ViewBag.From/@ViewBag.Take==i)
                        {<text>@(i + 1) </text>}
                    else
                    {
                        @Html.ActionLink((i + 1).ToString(),
                                        null,
                                        "Players",
                                        new
                                        {
                                            letter = @ViewBag.Letter,
                                            from = (i * @ViewBag.Take),
                                            take = @ViewBag.Take
                                        },
                                        null)
                        <text> </text>
                    }
                }
                >
            </center>
        </th>
    </tr>
    }
    <tr>
        <td colspan="5" align="center">
            @using (Html.BeginForm("Index", "Players", FormMethod.Get))
            {
                <input type="hidden" name="letter" id="letter" value="@ViewBag.Letter" />
                <text>Wyświetl </text>@Html.DropDownList("take", new SelectList(new[]{new KeyValuePair<string, int>("5",5),
                                                        new KeyValuePair<string, int>("7", 7),
                                                        new KeyValuePair<string, int>("10", 10)},
                                                        "Value", "Key"));
                <text>pozycji na stronie.</text>
                                                               
                <input type="submit" value="Zatwierdź" />
            }
        </td>
    </tr>
</table>
</center>